// 涉案金额
var saleM_Site = echarts.init(document.getElementById('saleM_Site'));
$.get("data/不同区域的各指标数据.json").done(function (data) {
    // data = JSON.parse(data),
    data = {
        "where": ["广州","深圳","东莞","佛山","珠海" ],
        "sale": [
            {"value":283122,"name":"广州"},
            {"value":253597,"name":"深圳"},
            {"value":299874,"name":"东莞"},
            {"value":260256,"name":"佛山"},
            {"value":186585,"name":"珠海"}],
            
            "order":[
            {"value":9097,"name":"广州"},
            {"value":5597,"name":"深圳"},
            {"value":8608,"name":"东莞"},
            {"value":7602,"name":"佛山"},
            {"value":4865,"name":"珠海"}],
            
            "gross":[
            {"value":146805,"name":"广州"},
            {"value":104936,"name":"深圳"},
            {"value":157321,"name":"东莞"},
            {"value":160256,"name":"佛山"},
            {"value":186585,"name":"珠海"}],
            
            "unit":[
            {"value":12.07,"name":"广州"},
            {"value":9.13,"name":"深圳"},
            {"value":11.03,"name":"东莞"},
            {"value":14.8,"name":"佛山"},
            {"value":12.6,"name":"珠海"}]
    },
        saleM_Site.setOption({
            tooltip: {
                trigger: 'item',
                formatter: "{b}：<br/>{c} 元<br/>（{d}%）"
            },
            legend: {
                type: 'scroll',
                data: data.where
            },
            toolbox: {
                show: false,
                feature: {
                    mark: { show: true },
                    dataView: { show: true, readOnly: false },
                    magicType: {
                        show: true,
                        type: ['pie', 'funnel']
                    },
                    restore: { show: true },
                    saveAsImage: { show: true }
                }
            },
            calculable: true,
            series: [
                {
                    name: '地点',
                    type: 'pie',
                    radius: ["25%", '60%'],
                    center: ['50%', '57%'],
                    roseType: 'area',
                    label: {
                        show: true,
                        formatter: '{c}'
                    },
                    data: data.sale
                },
                {
                    type: 'pie', radius: '25%', center: ['50%', '57%'],
                    label: { normal: { position: 'center', color: '#fff' } },
                    labelLine: { normal: { show: false } }, itemStyle: { color: 'transparent' },
                    data: [{ value: 1, name: '地点', tooltip: { formatter: ' ', backgroundColor: 'none' } }]
                },
            ]
        })
});



// 涉案数量
var orderQ_Site = echarts.init(document.getElementById('orderQ_Site'));
$.get("data/不同区域的各指标数据.json").done(function (data) {
    // data = JSON.parse(data),
    data = {
        "where": ["广州","深圳","东莞","佛山","珠海" ],
        "sale": [
            {"value":283122,"name":"广州"},
            {"value":253597,"name":"深圳"},
            {"value":299874,"name":"东莞"},
            {"value":260256,"name":"佛山"},
            {"value":186585,"name":"珠海"}],
            
            "order":[
            {"value":9097,"name":"广州"},
            {"value":5597,"name":"深圳"},
            {"value":8608,"name":"东莞"},
            {"value":7602,"name":"佛山"},
            {"value":4865,"name":"珠海"}],
            
            "gross":[
            {"value":146805,"name":"广州"},
            {"value":104936,"name":"深圳"},
            {"value":157321,"name":"东莞"},
            {"value":160256,"name":"佛山"},
            {"value":186585,"name":"珠海"}],
            
            "unit":[
            {"value":12.07,"name":"广州"},
            {"value":9.13,"name":"深圳"},
            {"value":11.03,"name":"东莞"},
            {"value":14.8,"name":"佛山"},
            {"value":12.6,"name":"珠海"}]
    },
        orderQ_Site.setOption({
            tooltip: {
                trigger: 'item',
                formatter: "{b}：<br/>{c} 个<br/>（{d}%）"
            },
            legend: {
                type: 'scroll',
                data: data.where
            },
            toolbox: {
                show: false,
                feature: {
                    mark: { show: true },
                    dataView: { show: true, readOnly: false },
                    magicType: {
                        show: true,
                        type: ['pie', 'funnel']
                    },
                    restore: { show: true },
                    saveAsImage: { show: true }
                }
            },
            calculable: true,
            series: [
                {
                    name: '地点',
                    type: 'pie',
                    radius: ["25%", '60%'],
                    center: ['50%', '57%'],
                    roseType: 'area',
                    label: {
                        show: true,
                        formatter: '{c}'
                    },
                    data: data.order
                },
                {
                    type: 'pie', radius: '25%', center: ['50%', '57%'],
                    label: { normal: { position: 'center', color: '#fff' } },
                    labelLine: { normal: { show: false } }, itemStyle: { color: 'transparent' },
                    data: [{ value: 1, name: '地点', tooltip: { formatter: ' ', backgroundColor: 'none' } }]
                },
            ]
        })
});



//烟草走私总额
var grossM_Site = echarts.init(document.getElementById('grossM_Site'));
$.get("data/不同区域的各指标数据.json").done(function (data) {
    // data = JSON.parse(data),
    data = {
        "where": ["广州", "深圳", "东莞", "佛山", "珠海"],
        "sale": [
            { "value": 283122, "name": "广州" },
            { "value": 253597, "name": "深圳" },
            { "value": 299874, "name": "东莞" },
            { "value": 260256, "name": "佛山" },
            { "value": 186585, "name": "珠海" }],

        "order": [
            { "value": 9097, "name": "广州" },
            { "value": 5597, "name": "深圳" },
            { "value": 8608, "name": "东莞" },
            { "value": 7602, "name": "佛山" },
            { "value": 4865, "name": "珠海" }],

        "gross": [
            { "value": 146805, "name": "广州" },
            { "value": 104936, "name": "深圳" },
            { "value": 157321, "name": "东莞" },
            { "value": 160256, "name": "佛山" },
            { "value": 186585, "name": "珠海" }],

        "unit": [
            { "value": 12.07, "name": "广州" },
            { "value": 9.13, "name": "深圳" },
            { "value": 11.03, "name": "东莞" },
            { "value": 14.8, "name": "佛山" },
            { "value": 12.6, "name": "珠海" }]
    },
        grossM_Site.setOption({
            tooltip: {
                trigger: 'item',
                formatter: "{b}：<br/>{c} 元<br/>（{d}%）"
            },
            legend: {
                type: 'scroll',
                data: data.where
            },
            toolbox: {
                show: false,
                feature: {
                    mark: { show: true },
                    dataView: { show: true, readOnly: false },
                    magicType: {
                        show: true,
                        type: ['pie', 'funnel']
                    },
                    restore: { show: true },
                    saveAsImage: { show: true }
                }
            },
            calculable: true,
            series: [
                {
                    name: '地点',
                    type: 'pie',
                    radius: ["25%", '60%'],
                    center: ['50%', '57%'],
                    roseType: 'area',
                    label: {
                        show: true,
                        formatter: '{c}'
                    },
                    data: data.gross
                },
                {
                    type: 'pie', radius: '25%', center: ['50%', '57%'],
                    label: { normal: { position: 'center', color: '#fff' } },
                    labelLine: { normal: { show: false } }, itemStyle: { color: 'transparent' },
                    data: [{ value: 1, name: '地点', tooltip: { formatter: ' ', backgroundColor: 'none' } }]
                },
            ]
        })
});



// 每个案子平均涉案金额
var unitP_Site = echarts.init(document.getElementById('unitP_Site'));
$.get("data/不同区域的各指标数据.json").done(function (data) {
    // data = JSON.parse(data),
    data = {
        "where": ["广州", "深圳", "东莞", "佛山", "珠海"],
        "sale": [
            { "value": 283122, "name": "广州" },
            { "value": 253597, "name": "深圳" },
            { "value": 299874, "name": "东莞" },
            { "value": 260256, "name": "佛山" },
            { "value": 186585, "name": "珠海" }],

        "order": [
            { "value": 9097, "name": "广州" },
            { "value": 5597, "name": "深圳" },
            { "value": 8608, "name": "东莞" },
            { "value": 7602, "name": "佛山" },
            { "value": 4865, "name": "珠海" }],

        "gross": [
            { "value": 146805, "name": "广州" },
            { "value": 104936, "name": "深圳" },
            { "value": 157321, "name": "东莞" },
            { "value": 160256, "name": "佛山" },
            { "value": 186585, "name": "珠海" }],

        "unit": [
            { "value": 1207, "name": "广州" },
            { "value": 9130, "name": "深圳" },
            { "value": 1103, "name": "东莞" },
            { "value": 148, "name": "佛山" },
            { "value": 126, "name": "珠海" }]
    },
        unitP_Site.setOption({
            tooltip: {
                trigger: 'item',
                formatter: "{b}：<br/>{c} 元<br/>（{d}%）"
            },
            legend: {
                type: 'scroll',
                data: data.where
            },
            toolbox: {
                show: false,
                feature: {
                    mark: { show: true },
                    dataView: { show: true, readOnly: false },
                    magicType: {
                        show: true,
                        type: ['pie', 'funnel']
                    },
                    restore: { show: true },
                    saveAsImage: { show: true }
                }
            },
            calculable: true,
            series: [
                {
                    name: '地点',
                    type: 'pie',
                    radius: ["25%", '60%'],
                    center: ['50%', '57%'],
                    roseType: 'area',
                    label: {
                        show: true,
                        formatter: '{c}'
                    },
                    data: data.unit
                },
                {
                    type: 'pie', radius: '25%', center: ['50%', '57%'],
                    label: { normal: { position: 'center', color: '#fff' } },
                    labelLine: { normal: { show: false } }, itemStyle: { color: 'transparent' },
                    data: [{ value: 1, name: '地点', tooltip: { formatter: ' ', backgroundColor: 'none' } }]
                },
            ]
        })
});



// 涉案数量城市Top10
var saleMtop10 = echarts.init(document.getElementById('saleMtop10'));
$.get("data/商品销售数量前10.json").done(function (data) {
    // data = JSON.parse(data),
    data = {
        "城市名称": ["广州","深圳","东莞","佛山","珠海","汕头","韶关","江门","湛江","肇庆"],
        "案件数量": [3, 5, 6, 9, 9, 10, 13, 13, 16, 21]
    },
        saleMtop10.setOption({
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            grid: {
                left: '0%',
                top: '20',
                right: '2%',
                bottom: '10',
                containLabel: true
            },
            barCategoryGap: '40%',
            xAxis: {
                type: 'value',
                min: 0,
                interval: 5,
                boundaryGap: [0, 0.01],
                axisLine: { lineStyle: { width: 0 } },
            },
            yAxis: {
                type: 'category',
                splitLine: { lineStyle: { width: 0 } },
                data: data.城市名称
            },
            series: [
                {
                    name: '案件总数量',
                    type: 'bar',
                    label: {
                        position: 'right',
                        verticalAlign: 'middle',
                    },
                    data: data.案件数量
                }
            ]
        })
});



// 商品价格区间
var priceRange = echarts.init(document.getElementById('priceRange'));
$.get("data/商品销量数量和价格数据.json").done(function (data) {
    // data = JSON.parse(data),
    data = {
        "data": [
            {"value":[6.5,8],"name":"双喜"},
            {"value":[1.8,13],"name":"五叶神"},
            {"value":[3.5,13.5],"name":"椰树"},
            {"value":[2.6,9],"name":"羊城"},
            {"value":[3.8,14],"name":"红玫"},
            {"value":[1.5,22],"name":"好日子"},
            {"value":[4.5,10.5],"name":"阿里山"},
            {"value":[5.5,18],"name":"特美思"},
            {"value":[4.8,16],"name":"玉溪"},
            {"value":[4.8,16],"name":"芙蓉王"}
        ]
    },
        priceRange.setOption({
            grid: {
                left: '3%',
                right: '10',
                bottom: '10',
                containLabel: true
            },
            tooltip: {
                showDelay: 0,
                formatter: function (params) {
                    return params.seriesName + '<br/>'
                        + '单价：' + params.value[0] + '<br/>'
                        + '销量：' + params.value[1];
                },
                axisPointer: {
                    show: true,
                    type: 'cross',
                    lineStyle: {
                        type: 'dashed',
                        width: 1
                    }
                }
            },

            legend: {
                type: 'scroll',
            },
            xAxis: { scale: true },
            yAxis: { scale: true },
        })
});
$.get("data/商品销量数量和价格数据.json").done(function (data) {
    // data = JSON.parse(data);
    data = {
        "data": [
            {"value":[6.5,8],"name":"双喜"},
            {"value":[1.8,13],"name":"五叶神"},
            {"value":[3.5,13.5],"name":"椰树"},
            {"value":[2.6,9],"name":"羊城"},
            {"value":[3.8,14],"name":"红玫"},
            {"value":[1.5,22],"name":"好日子"},
            {"value":[4.5,10.5],"name":"阿里山"},
            {"value":[5.5,18],"name":"特美思"},
            {"value":[4.8,16],"name":"玉溪"},
            {"value":[4.8,16],"name":"芙蓉王"}
        ]
    };
    var series = [];
    for (var i = 0; i < data.data.length; i++) {
        series.push({
            name: data.data[i].name,
            type: 'scatter',
            data: [data.data[i].value],
            symbolSize: data.data[i].value[1] * 2
        });
    }
    priceRange.setOption({
        series: series
    });
});



// 涉案金额预测值与实际值
var saleAll = echarts.init(document.getElementById('saleAll'));
$.get("data/商品销量数量和价格数据.json").done(function (data) {
    // data = JSON.parse(data),
    data = {
        "D": ["1��", "2��", "3��", "4��", "5��", "6��", "7��", "8��", "9��", "10��", "11��", "12��", "13��", "14��", "15��", "16��", "17��", "18��", "19��", "20��", "21��", "22��"],
        "T": [1.2, 1.4, 1.3, 1.1, 1.2, 0.8, 1.2, 1.1, 1.4, 1.7, 1.3, 1.2, 1.4, 1.5, 1.1, 1.2, 0.9, 1.2, 1.1, 1.4, 1.5, 1.3],
        "Y": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    },
        saleAll.setOption({
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                type: 'scroll'
            },
            grid: {
                left: '10',
                right: '20',
                bottom: '10',
                containLabel: true
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: ['1日', '2日', '3日', '4日', '5日', '6日', '7日', '8日', '9日', '10日',
                    '11日', '12日', '13日', '14日', '15日', '16日', '17日', '18日', '19日', '20日', '21日', '22日']
            },
            yAxis: {
                type: 'value',
                name: '金额（万元）',
                axisLabel: {
                    formatter: '{value}'
                }
            },
            series: [
                {
                    name: '涉案金额实际值',
                    type: 'line',
                    data: data.T,
                    areaStyle: {
                        normal: {
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: 'rgba(194, 53, 49,.8)'
                            }, {
                                offset: 1,
                                color: 'transparent'
                            }])
                        }
                    },
                },
                {
                    type: 'line',
                    name: '涉案金额预测值',
                    data: data.Y,
                    areaStyle: {
                        normal: {
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: 'rgba(47, 69, 84,.4)'
                            }, {
                                offset: 1,
                                color: 'transparent'
                            }])
                        }
                    }
                },
            ]
        })
});



window.onresize = function () {
    saleM_Site.resize();
    orderQ_Site.resize();
    grossM_Site.resize();
    unitP_Site.resize();
    saleMtop10.resize();
    priceRange.resize();
    saleAll.resize();
}